Essential Object Oriented Design in Ruby by Bala Paranj

Essential Object Oriented Design in Ruby by Bala Paranj

Author:Bala Paranj [Paranj, Bala]
Language: eng
Format: epub, pdf
Published: 2016-03-20T23:00:00+00:00


Step 2

Let's extract the logic to find if anyone has a birthday today.

# Person and PersonFileStore classes is same as before.

# This class encapsulates the logic to find out if the birthday is today or not.

# It has no dependency on other objects

class BirthDay

def initialize(month, day)

@month = month

@day = day

end

def today?

(@month.to_i == Date.today.month) and (@day.to_i == Date.today.day)

end

end

pfs = PersonFileStore.new("#{Dir.pwd}/data.txt")

records = pfs.records

records.each do |person|

month = person.birth_month

day = person.birth_day



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.